import { InjectionKey } from "vue";
import { createStore, useStore as baseUseStore, Store } from "vuex";
import dictionary, { dictionaryProps } from "./modules/dictionary";
import catalog, { catalogProps } from "./modules/catalog";
import user, { userProps } from "./modules/user";
import getters from "./getters";
export interface GlobalDataProps {
	dictionary: dictionaryProps;
	user: userProps,
	catalog: catalogProps
}
// 定义 injection key
export const key: InjectionKey<Store<GlobalDataProps>> = Symbol();
//createStore接收一个泛型来定义根state的类型
export const store = createStore<GlobalDataProps>({
	getters,
	modules: {
		dictionary,
		user,
		catalog
	},
});
// 定义自己的 `useStore` 组合式函数
export function useStore() {
	return baseUseStore(key);
}
